//
// Created by 李传智 on 2018/4/12.
//

#include "IObserver.h"


void IObserver::addObserver(IObserver *observer) {
    if (!observer) {
        return;
    }
    mutex.lock();
    observers.push_back(observer);
    mutex.unlock();
}

void IObserver::notify(VideoData data) {
    mutex.lock();
    int size = observers.size();
    for (int i = 0; i < size; ++i) {
        observers[i]->update(data);
    }
    mutex.unlock();
}